<template>
  <div id="app">
    <table class="tb">
      <tr>
        <th><h3>欢迎光临</h3></th>
      </tr>
      <tr>
        <td>苹果 {{ num }} 元/斤，折扣（八折）</td>
      </tr>
      <tr>
        <td>
          输入购买数量
          <input type="number" v-model="shuliang" />
        </td>
      </tr>
      <tr>
        <td>
          <button @click="btn">结算</button>
        </td>
      </tr>
      <tr>
        <td>
          结账单：总价￥ {{ money * 1 }} ，折后价：￥
          {{ money * 0.8 }}，省了：￥
          {{ money * 0.2 }}
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      num: 8,
      shuliang: 0,
      money: "",
    };
  },
  methods: {
    btn() {
      this.money = this.shuliang * this.num;
    },
  },
};
</script>

<style>
#app {
  width: 600px;
  margin: 10px auto;
}

.tb {
  border-collapse: collapse;
  width: 100%;
}

.tb th {
  background-color: #0094ff;
  color: white;
}

.tb td,
.tb th {
  padding: 5px;
  border: 1px solid black;
  text-align: center;
}

.add {
  padding: 5px;
  border: 1px solid black;
  margin-bottom: 10px;
}
</style>

<style scoped>
</style>

